Repository navigation
feat: event page shows the basket; changing it adds or removes attendees - #13
Merged
Merged
Conversation
Back on the event page, the "Get tickets" form now shows the tickets already in the basket for that event, with Event Tickets' own "already in your cart" notice. assets/js/basket.js fetches them through admin-ajax (tsharp_basket) after the page loads, since event pages are often cached. A form filled that way posts tsharp_basket=1, and CartHandler then sets the basket's quantities to the posted ones instead of adding them: more adds attendees, fewer leaves the last ones out, zero removes the ticket, and a rise goes through WooCommerce's update-cart validation so capacity holds. The buyer goes on to the attendee details page. Until the basket has been fetched, the form adds as before, so it can never empty a basket by mistake. Attendee details already entered are never lost: answers beyond the quantity stay on the cart line (not copied to the order or shown in the basket), and a ticket taken out of the basket has its answers set aside in the WooCommerce session and restored if it is added again. Checkout clears them.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The journey: on the event page press add twice, then Get tickets, which goes to attendee information. Go back to the event page and the form now shows 2. Changing the numbers and pressing Get tickets again adds or removes attendees on the attendee information page, without losing anything already entered.
Event page (
assets/js/basket.js,views/tickets-form-fields.php)admin-ajax.php?action=tsharp_basket; event pages are often cached, so it can't be in the HTML), fills in the quantities and shows Event Tickets' own "tickets already in your cart" notice. It asks again when the page is restored by the Back button.tsharp_basket=1. Until the answer arrives, or if it fails, the form adds as it always has, so a form still showing 0 can never empty a basket.Get tickets (
CartHandler)tsharp_basket=1the posted quantities replace the basket's for that event: more adds attendees, fewer leaves the last ones out, 0 removes the ticket. A rise goes throughwoocommerce_update_cart_validation, so capacity holds. The buyer then goes to attendee information when any ticket asks for it, otherwise to checkout; with nothing of the event left, back to the event page.tickets_sharp/basket_changed.Attendee details are never lost (
DetailsPage)woocommerce_cart_emptied(checkout) clears them.Checks. Local gates (
ci-local tickets-sharp, PHP 8.4) pass: 309 tests, PHPStan, PHPCS. Not yet tried in a browser on a site with WooCommerce; staging63 is next.Known limit. Event Tickets disables Get tickets when every quantity is 0, so the whole basket can't be emptied from the event page; the basket page still does that.
Merging releases a minor version (0.6.0).